package com.wanglei.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanglei.domain.entity.Role;
import com.wanglei.service.RoleService;
import com.wanglei.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author MrWang
* @description 针对表【sys_role(角色信息表)】的数据库操作Service实现
* @createDate 2023-07-10 16:15:53
*/
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role>
    implements RoleService{

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<String> selectRolesByUserId(Long id) {
        //如果是超级管理员 返回admin即可
        if (id==1){
            List<String> roleKeys = new ArrayList<>();
            roleKeys.add("admin");
            return roleKeys;
        }
        //否则查询用户所具有的角色信息
        return roleMapper.selectRolesByUserId(id);
    }
}




